package com.example.springboot.common;

import lombok.Data;

/**
 * @Author:Domen
 * @Date:2023/11/8 16:29
 */

@Data
public class Result {

    private static final String SUCCESS_CODE = "200";
    private static final String ERROR_CODE = "-1";

    private String code;    //返回给前端的状态码
    private Object data;    //返回给前端的数据
    private String msg;     //返回信息

    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        return result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return result;
    }

    public static Result error(String msg){
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMsg(msg);
        return result;
    }


}
